package top.lshaci.learning.nio;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;

/**
 * NioFileChannelCopy
 *
 * @author lshaci
 * @since 1.0.0
 */
public class NioFileChannelTransfer {

    public static void main(String[] args) throws Exception {
        String filename = "D:\\System\\Pictures\\24a95d46cd99568b.jpg";
        FileInputStream fis = new FileInputStream(filename);

        final FileChannel inChannel = fis.getChannel();
        FileOutputStream fos = new FileOutputStream("E:/1.jpg");

        final FileChannel outChannel = fos.getChannel();
        outChannel.transferFrom(inChannel, 0, fis.available());

        fis.close();
        fos.close();
    }
}
